<template>
 <div class="container">
   <div class="card-search cardTop">
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="成型工单" name="profileOrder"></el-tab-pane>
      <el-tab-pane label="产品列表" name="profileQuality"></el-tab-pane>
    </el-tabs>
   </div>
   <div class="card-table">
    <profileOrder v-if="profileOrderif" />
    <profileQuality v-if="profileQualityif" />
   </div>
 </div>
</template>

<script>
import profileOrder from './profileOrder/index.vue'
import profileQuality from '../profiling/profileQuality'
// import '@/mock/dataCenter.js'

export default {
  name: 'profileQuaSide',
  components: {
    profileOrder,
    profileQuality
  },
  data () {
    return {
      activeName: 'profileOrder',
      profileOrderif: true,
      profileQualityif: false
    }
  },
  computed: {
  },
  created () {
    if (sessionStorage.getItem('activeTab')) {
      this.activeName = sessionStorage.getItem('activeTab')
      console.log('this', this.activeName)
      this.profileOrderif = false
      this.profileQualityif = false
      switch (sessionStorage.getItem('activeTab')) {
        case 'profileOrder':
          this.profileOrderif = true
          break
        case 'profileQuality':
          this.profileQualityif = true
          break
        default:
          break
      }
    } else {
      sessionStorage.setItem('activeTab', this.activeName)
    }
  },
  beforeRouteLeave (to, from, next) {
    sessionStorage.removeItem('activeTab')
    next()
  },
  mounted () {
  },
  methods: {
    handleClick (tab) {
      // console.log('tab', tab)
      sessionStorage.setItem('activeTab', tab.name)
      this.profileOrderif = false
      this.profileQualityif = false
      switch (tab.index) {
        case '0':
          this.profileOrderif = true
          break
        case '1':
          this.profileQualityif = true
          break
        default:
          break
      }
    }
  }
}
</script>

<style  scoped>
.block{
  margin-top: 20px;
  text-align: right;
}
.container {
  .cardTop {
    padding: 0 18px 0px;
    .el-tabs {
      .el-tabs__header {
        width: 300px;
      }
    }
  }
}
</style>
